#!usr/bin/perl
use Data::Dumper;

sub parse_class {
	my $tcher_info_time = $_[0];
	my $tcher_info_fre = $_[1];
	my $ifile = $_[2];
	
  my $class_name;
	open($fh,$ifile) or die("cannot open file $ifile\n");
	while(<$fh>) {
		chmop;
		my $line = $_;
    
		my %week; 
    my %time_range;
    if ($line =~ /class=(\w+);/) {
			my $name = $1;
			$class_name = $name;
		}
		if ($line =~ /星期一(\w+):(\w+)-(\w+):(\w+);/) {
			my $st_time = $1 . $2;
			my $ed_time = $3 . $4;
      my %time_range_1;
			$time_range_1->{st_time} = $st_time;
			$time_range_1->{ed_time} = $ed_time;
      %time_range = %$time_range_1;
			$week->{1} = $time_range_1;
		}
		if ($line =~ /星期二(\w+):(\w+)-(\w+):(\w+);/) {
                        my $st_time = $1 . $2;
			my $ed_time = $3 . $4;
      my %time_range_2;
                        $time_range_2->{st_time} = $st_time;
                        $time_range_2->{ed_time} = $ed_time;
                        %time_range = %$time_range_2;
                        $week->{2} = $time_range_2;
                }
		if ($line =~ /星期三(\w+):(\w+)-(\w+):(\w+);/) {
                        my $st_time = $1 . $2;
			my $ed_time = $3 . $4;
      my %time_range_3;
                        $time_range_3->{st_time} = $st_time;
                        $time_range_3->{ed_time} = $ed_time;
      %time_range = %$time_range_3;
                        $week->{3} = $time_range_3;
                }
		if ($line =~ /星期四(\w+):(\w+)-(\w+):(\w+);/) {
                        my $st_time = $1 . $2;
			my $ed_time = $3 . $4;
      my %time_range_4;
                        $time_range_4->{st_time} = $st_time;
                        $time_range_4->{ed_time} = $ed_time;
                        $week->{4} = $time_range_4;
                }
		if ($line =~ /星期五(\w+):(\w+)-(\w+):(\w+);/) {
                        my $st_time = $1 . $2;
			my $ed_time = $3 . $4;
      my %time_range_5;
                        $time_range_5->{st_time} = $st_time;
                        $time_range_5->{ed_time} = $ed_time;
                        $week->{5} = $time_range_5;
                }
    print "\n";
    my %week_ref;
    %week_ref = %$week;
		$tcher_info_time->{$class_name} = \%week_ref;
    undef $week;
    undef %time_range;
    undef $time_range_1;
    undef $time_range_2;
    undef $time_range_3;
    undef $time_range_4;
    undef $time_range_5;
		if ($line =~ /fre=(\w+);/) {
			my $fre = $1;
			$tcher_info_fre->{$class_name} = $fre;
		}
	}
	\%$tcher_info_time;
}

1

